home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 2 / csmp-v2-019.txt < prev    next >
Text File  |  1995-06-30  |  36KB  |  974 lines

  1. C.S.M.P. Digest             Sat, 13 Mar 93       Volume 2 : Issue 19
  2.  
  3. Today's Topics:
  4.  
  5.     Scope of trap patches
  6.     HELP! What IS this bug
  7.     appleevents
  8.     Help with strings....
  9.     Getting a dirID from an FSSpec. HELP!
  10.  
  11.  
  12.  
  13. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  14.  
  15. The digest is a collection of article threads from the usenet newsgroup
  16. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  17. regularly and want an archive of the discussions.  If you don't know what a
  18. newsgroup is, you probably don't have access to it.  Ask your systems
  19. administrator(s) for details.  If you don't have access to news, you can
  20. post articles to any newsgroup by mailing your article to
  21.     newsgroup@cs.utexas.edu
  22. So, to post an article to comp.sys.mac.programmer, mail your article to
  23.     comp-sys-mac-programmer@cs.utexas.edu
  24. Note the '-' instead of '.' in the newsgroup name.  Be sure to ask that
  25. replies be emailed to you instead of posted to the group, and give your
  26. email address.
  27.  
  28. Each issue of the digest contains one or more sets of articles (called
  29. threads), with each set corresponding to a 'discussion' of a particular
  30. subject.  The articles are not edited; all articles included in this digest
  31. are in their original posted form (as received by our news server at
  32. cs.uoregon.edu).  Article threads are not added to the digest until the last
  33. article added to the thread is at least one month old (this is to ensure that
  34. the thread is dead before adding it to the digest).  Article threads that
  35. consist of only one message are generally not included in the digest.
  36.  
  37. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  38. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  39. file /pub/mac/csmp-digest/README before downloading any files.  The most
  40. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  41. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  42. archive has a mail server; send a message with the text '$MACarch help' (no
  43. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  44.  
  45. The digest is also available via email.  Just send a note saying that you
  46. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  47. automatically receive each new issue as it is created.  Sorry, back issues
  48. are not available through the mailing list.
  49.  
  50. Send administrative mail to mkelly@cs.uoregon.edu.
  51.  
  52.  
  53. -------------------------------------------------------
  54.  
  55. From: lardieri@ernie.Princeton.EDU (Stephen Peter Lardieri)
  56. Subject: Scope of trap patches
  57. Organization: Princeton University
  58. Date: Sun, 7 Feb 1993 03:26:31 GMT
  59.  
  60. It would appear, under System 7.1, that an application calling
  61. SetTrapAddress or NSetTrapAddress only patches a trap with respect
  62. to itself -- other applications, launched either before or after
  63. the one doing the patching, still get the original, unpatched
  64. trap.
  65.  
  66. Is it possible to patch a trap in a global fashion from an application,
  67. so that all other apps will use the patched trap?  Or is the only
  68. way to do this with INIT code?
  69.  
  70.  
  71. +++++++++++++++++++++++++++
  72.  
  73. From: cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole)
  74. Date: Sun, 7 Feb 1993 06:40:00 GMT
  75. Organization: University of Illinois at Urbana
  76.  
  77. In <1993Feb7.032631.12987@Princeton.EDU> lardieri@ernie.Princeton.EDU (Stephen 
  78. Peter Lardieri) writes:
  79.  
  80. >It would appear, under System 7.1, that an application calling
  81. >SetTrapAddress or NSetTrapAddress only patches a trap with respect
  82. >to itself -- other applications, launched either before or after
  83. >the one doing the patching, still get the original, unpatched
  84. >trap.
  85.  
  86. Not just 7.1. Anything post-MultiFinder. In fact, Switcher (the ancestor of 
  87. sorts to MultiFinder) swapped out trap patches. 
  88.  
  89.  
  90. >Is it possible to patch a trap in a global fashion from an application,
  91. >so that all other apps will use the patched trap?  Or is the only
  92. >way to do this with INIT code?
  93.  
  94. Maybe there's a way, but from what I've seen of how the spawning of 
  95. applications works, you would need to hunt down every app's trap table off in 
  96. the undocumented (because you aren't supposed to fiddle or rely on it's 
  97. structure) memory zone that wraps around all the various applications. Apple is
  98. NOT likely to tell anyone how to mess around out there, but if you have a bit 
  99. of time and MacsBug you could snoop for the necessary info to do it.
  100.  
  101. (IOW: The only way is INIT code.)
  102.  
  103.  
  104. Bill Stewart-Cole
  105.  
  106. +++++++++++++++++++++++++++
  107.  
  108. Date: 7 Feb 93 23:12:26 GMT
  109. Organization: Royal Institute of Technology, Stockholm, Sweden
  110.  
  111. In <1993Feb7.032631.12987@Princeton.EDU> lardieri@ernie.Princeton.EDU (Stephen Peter Lardieri) writes:
  112.  
  113. >Is it possible to patch a trap in a global fashion from an application,
  114. >so that all other apps will use the patched trap?  Or is the only
  115. >way to do this with INIT code?
  116.  
  117. You answered your question yourself...
  118.  
  119. Cheers,
  120.  
  121.                         / h+
  122. - -- 
  123.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  124.    This signature is kept shorter than 4 lines in the interests of UseNet
  125.    S/N ratio.
  126.  
  127. +++++++++++++++++++++++++++
  128.  
  129. From: rmah@panix.com (Robert Mah)
  130. Organization: PANIX Public Access Unix, NYC
  131. Date: Mon, 8 Feb 1993 07:06:11 GMT
  132.  
  133. tte) writes:
  134.  
  135. >In <1993Feb7.032631.12987@Princeton.EDU> lardieri@ernie.Princeton.EDU (Stephen Peter Lardieri) writes:
  136.  
  137. >>Is it possible to patch a trap in a global fashion from an application,
  138. >>so that all other apps will use the patched trap?  Or is the only
  139. >>way to do this with INIT code?
  140.  
  141. I think (I am NOT sure) that if you set the new trap address to a location
  142. in the system heap then the patch will occur for all apps.  You would
  143. have to move the code into the system heap yourself.
  144.  
  145. Now, again, I'm not sure.  Can anyone confirm or deny this possibly unfounded
  146. rumor?
  147.  
  148. Cool Runnin'
  149. Rob
  150.  
  151. - -- 
  152. [----------------------------------------------------------------------]
  153. [ Robert S. Mah   | Voice: 212-947-6507   | "Every day an adventure,   ]
  154. [ One Step Beyond | EMail: rmah@panix.com |  every moment a challenge" ]
  155. [----------------------------------------------------------------------]
  156.  
  157. +++++++++++++++++++++++++++
  158.  
  159. From: lsr@taligent.com (Larry Rosenstein)
  160. Date: 8 Feb 93 22:07:45 GMT
  161. Organization: Taligent, Inc.
  162.  
  163. In article <C24BqB.L3H@panix.com>, rmah@panix.com (Robert Mah) wrote:
  164. > I think (I am NOT sure) that if you set the new trap address to a location
  165. > in the system heap then the patch will occur for all apps.  You would
  166.  
  167. That's not true under MultiFinder or System 7.  There's no clean way for an
  168. application to make a global trap patch.  It's not clear what that would
  169. mean if it was possible; would it apply to apps that are currently running?
  170.  
  171. Also, I don't think it is recommended for applications to allocate memory
  172. in the system heap when patching traps.  This used to be necessary for the
  173. 64K ROM tap dispatcher, but that was fixed a long time ago.
  174.  
  175. Larry Rosenstein
  176. Taligent, Inc.
  177.  
  178. lsr@taligent.com
  179.  
  180. ---------------------------
  181.  
  182. From: cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole)
  183. Subject: HELP! What IS this bug
  184. Organization: University of Illinois at Urbana
  185. Date: Thu, 4 Feb 1993 05:53:43 GMT
  186.  
  187. The bug I *THOUGHT* was a side effect of shoving a resource map into a commonly
  188. accessible spot turns out not to be that... The situation is that I have an 
  189. INIT which patches SystemTask in order to get some regular time, and it talks 
  190. to an external device via the serial port to determine whether to allow the 
  191. user to do anything. In shutting off the user, it does a little screen 
  192. blanking act and set SysEvtMask so that the mouse and keys are ignored. The 
  193. program can for various reasons have to dialog with the user, using dialogs in
  194. a file I now only open as needed (and to hell with the user who moves it out 
  195. from under me) The bug is that when I try to open a desk accessory, especially
  196. one which opens a dialog as it's priomary interface (Chooser and Quill for 
  197. example) I get crashes in the data area of CDEF and WDEF'strying to open a DA  before that file has ever even been 
  198. touched, and I am seeing the SAME errors. Sadly, reproducibility is bad, with 
  199. errors coming in different def functions every time I change a line of code 
  200. (say top put a Debugger() call in, or an extra null pointer check) and coming 
  201. in different ones for the 2 most consistent problem DA's (Chooser and Quill, 
  202. both of which use a dialog box as main interface, and both of which are 
  203. crashing inside the GetNewDialog call they use to get the dialog) 
  204.  
  205. I have determined that the suspect of the day is something I'm doing evil in 
  206. QuickDraw. I use no QD but for a call to NewRgn in the INIT code, and in the 
  207. SystemTask patch I presumeably will always have an app's A5 to base my new 
  208. GrafPort on ( I use a raw GrafPort to blank the screen and draw a snide little
  209. migrating message to the user) and I only have my GrafPort aroubnd when the 
  210. screen is blanked, so I THOUGHT I wouldn't have to fake out an InitGraf call, 
  211. and in fact that it would be daBug work is a bit tedious since by 
  212. the time I have a crash I am pretty far down the stack from the actual DA, and
  213. have passed thru a LOT of code and have a rather short A6 chaindue to some 
  214. upstream ROM patches presumeably done by Apple (this is system 7 on a Plus, so
  215. I am chock full of patches that never LINK A6 to give me a clear path)
  216.  
  217.  
  218.  
  219.  
  220.  
  221. +++++++++++++++++++++++++++
  222.  
  223. From: ray@netcom.com (Ray Fischer)
  224. Date: 7 Feb 93 21:41:41 GMT
  225. Organization: Netcom. San Jose, California
  226.  
  227. cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole) writes ...
  228. >The bug I *THOUGHT* was a side effect of shoving a resource map into a commonly
  229. >accessible spot turns out not to be that... The situation is that I have an 
  230. >INIT which patches SystemTask in order to get some regular time, and it talks 
  231. >to an external device via the serial port to determine whether to allow the 
  232. >user to do anything.
  233.  
  234. I don't know what you're trying to do, but in my opinion you're not
  235. suffering nearly enough for some of the truly strange things you're
  236. doing.  No, it's probably not reasonable to assume A5 will be valid
  237. everytime you intercept SystemTask.  Were I writing this sort of
  238. program, I'd probably make it a faceless background application with
  239. its own A5 world, globals, stack, heap, and all those other things
  240. that make writing programs so much easier.
  241.  
  242. - -- 
  243. Ray Fischer                   "Convictions are more dangerous enemies of truth
  244. ray@netcom.com                 than lies."  -- Friedrich Nietzsche
  245.  
  246. +++++++++++++++++++++++++++
  247.  
  248. From: cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole)
  249. Date: Mon, 8 Feb 1993 05:24:20 GMT
  250. Organization: University of Illinois at Urbana
  251.  
  252.  
  253. In <1993Feb7.214141.8854@netcom.com> ray@netcom.com (Ray Fischer) writes:<
  254. <
  255. >>accessible spot turns out not to be that... The situation is that I have an <
  256. >>INIT which patches SystemTask in order to get some regular time, and it
  257. talks <
  258. >>to an external device via the serial port to determine whether to allow the <
  259. >>user to do anything.<
  260. <
  261. >I don't know what you're trying to do, but in my opinion you're not<
  262. >suffering nearly enough for some of the truly strange things you're<
  263. >doing.  No, it's probably not reasonable to assume A5 will be valid<
  264. <
  265. How sweet of you. :P <
  266. The point of this whole thing is machine control. Make the user put a card into
  267. a box, and don't let the mac look at events until the card reader says OK.
  268. Blank the screen even. The client may even be asking for Mac-controlled
  269. handcuffs to keep the user from leaving if he tries to cheat the system. (okay,
  270. maybe not THAT bad) And actually, I tracked the beast for a while and found
  271. that indeed A5 was valid consistently. It was a different valid  set of QD
  272. globals involved, but it always was a valid A5. Turns out that wasn't the
  273. problem.<
  274. <
  275. >everytime you intercept SystemTask.  Were I writing this sort of<
  276. >program, I'd probably make it a faceless background application with<
  277. >its own A5 world, globals, stack, heap, and all those other things<
  278. >that make writing programs so much easier.<
  279. <
  280. But that makes it impossible to make secure. Try a cmd-opt-esc on any
  281. application, no  matter how invisible it is. Also, since this evil little
  282. fascist INIT is aimed at making people pay for time used on a Mac, it also
  283. controls printing, so has to patch PrGlue. You can't do global trap patches
  284. from anywhere but an INIT. (also, since this is a INIT that loads into the
  285. system heap, detaches, and locks itself in for the duration, it has a perfectly
  286. good heap without any of the management problems. As long as it has someones A5
  287. to leech off of for QD globals, the rest of the internal globals are just
  288. managed thru A4 and are a non-issue. It's impossible to ever run on a mac
  289. without a stack)<
  290. <
  291. The solution to this mess was not in going to some sort of other form of code,
  292. but in taking a closer look at what *I* was doing. Seems that in the course of
  293. leeching time from the system in places other than SystemTask and using them to
  294. call SystemTask when my main patch was getting bored (like amidst 50k-line
  295. compiles or launching Word) I failed to totally deal with a little re-entrancy
  296. problem that was resulting in the potential for drivers (or DA's, whcih are
  297. just public-access drivers, sorta like cabbies.) to effectively be re-entered
  298. once if they happened to make certain calls during initialization. I got no
  299. infinite recursions, but I did get that really wigged behavior and crashes in
  300. certain DA's. The fix was to give up on helping out the OS by cvalling
  301. SystemTask when no app had recently, and instead just do what *I* needed to do
  302. to keep my little outside controller happy (it insists on a ping-pong every 
  303. minute, and gives me less than 10 seconds to respond before it errors out, 
  304. leaving my software no choice but to kill the user... figurative at this alpha
  305. stage, but the client is interested in making that part literal I think) 
  306.  
  307.  
  308. Bill Stewart-Cole
  309.  
  310. ---------------------------
  311.  
  312. From: joshr@kronos.arc.nasa.gov (Joshua Rabinowitz-Summer-91)
  313. Subject: appleevents
  314. Date: 8 Jan 93 22:08:23 GMT
  315. Organization: NASA/ARC Information Sciences Division
  316.  
  317.  
  318. Hey all:
  319. I`ve been working for quite some time now on a program that runs
  320. concurrently and closely with hypercard.
  321.  
  322. I would like to send misc/dosc events from hypercard to my app.
  323. (and vice/versa)
  324. I have it working from my app to hypercard, but the hypercard
  325. error messages are not passed back correctly.  The notiication manager
  326. blinks the multifinder icon in top right with the HC icon, but I don't
  327. think tthere is any other sign that there was an error.  The user must
  328. switch to HC before recieving the error message.
  329.  
  330. What I would like is
  331. 1) when my app sends an AE to hypercard, it waits for HC to finish,
  332. and READS `the result' out of the returned ae.  Currently it sends it and
  333. waits for HC to finish, but does not unload "the result" from the
  334. reply.  In addition, HC does not appear to work any faster in the background
  335. while processing the AE than any other time. Cant the client somehow give up
  336. almost all CPU time while waiting for the AE to finish?
  337.  
  338. 2) To be able to send dosc events to my program.  I think I know how
  339. to send it (using the SendAppleEvent XCMD stack), but I am unclear on the
  340. TCL half of the receiving.  I know that when it comes into the event loop,
  341. it will be packaged by TCL into a CAppleEvent.  But I am
  342. unclear what to do next.  Has anyone written, or know of, a
  343. dosc handler code for tcl (or straight C?)
  344.  
  345. I would be happy to share my existing code.
  346. If anyone is familiar with these issues, and could help me troublewhoot
  347. this, pls. give me a hand.
  348.  
  349. joshr@kronos.arc.nasa.gov
  350.  
  351. PS - email is better for me than News.
  352.  
  353. Following find Think C code for my "Send Hypercard Script" function
  354. If someone can see me making some mistakes, I'd be real thankful for
  355. the tips.
  356.  
  357.  
  358.  
  359.  
  360. /****************************************************/
  361. #include "SendToHyp.h"
  362. #include <Exceptions.h>
  363. #include "Constants.h"
  364. #include <TBUtilities.h>
  365.  
  366. extern CursHandle            gWatchCursor;`
  367. /* Watch cursor for waiting            */
  368.  
  369. Boolean SendToHypercard(char *messageToSend) 
  370. {
  371.   // mostly from Programming for SYS7, p. 145
  372.    // pseudocode:
  373.    
  374.    //   GetProcessInformation()
  375.    // create address descriptor from above info
  376.    
  377.    // create apple event with AECreateAppleEvent() and 
  378.    // pass it address descriptor
  379.    //  use AEManager to add descriptors with AEPutParamPtr or AEPutParamDesc
  380.    // call AESend
  381.    // check for errors
  382.    // dispose of copies of descriptor records
  383.    // process the AEReply
  384.    
  385.    AEAddressDesc     theAddressDesc;
  386.    AEDesc        theResultDescriptor;
  387.    AppleEvent     theAE, theReply;
  388.    OSErr         myError, sendError;
  389.    TargetID     myTarget;
  390.    PortInfoRec    myPortInfo;
  391.    DescType     actualType, theDescriptorType;
  392.    long         eventError, actualSize, theResultSize;
  393.    ProcessSerialNumber process;
  394.    Boolean fSentSuccess = FALSE;
  395.    
  396.    if (FindHypercardProcessNumber(&process) == FALSE) 
  397.        return FALSE;
  398.  
  399.        
  400.        // create descriptor of serial number
  401.        myError = AECreateDesc(typeProcessSerialNumber, (Ptr)&process, 
  402.           sizeof(process), &theAddressDesc);
  403.        FailOSErr(myError);
  404.     
  405.         // create the apple event
  406.        myError = AECreateAppleEvent(kHypercardMessageEventClass, 
  407.                kHypercardMessageEventID, 
  408.           &theAddressDesc, kAutoGenerateReturnID,
  409.                kAnyTransactionID, &theAE); 
  410.        FailOSErr(myError);
  411.        
  412.        // dispose of descriptor, (which is now copied into the AE ?)
  413.        myError = AEDisposeDesc( &theAddressDesc);   
  414.        /* we don't need it anymore */
  415.        FailOSErr(myError);
  416.           
  417.        // put the string in a a ParamPtr
  418.        myError = AEPutParamPtr(&theAE, keyDirectObject, typeChar, 
  419.           messageToSend, strlen(messageToSend) );
  420.        FailOSErr(myError);
  421.        
  422.        SetCursor(*gWatchCursor);
  423.        /*** SHOW WATCH CURSOR ***/
  424.        
  425.        //printf("sending\n");    /// ** DEBUGGING
  426.        
  427.        // Send it 
  428.        sendError = AESend(&theAE, &theReply, 
  429.            kAEWaitReply + kAECanInteract, kAEHighPriority, 
  430.           kNoTimeOut, myIdleProc, 0L);
  431.        
  432.        if (sendError) {
  433.           myError = AEDisposeDesc(&theAE);
  434.           FailOSErr(sendError);
  435.           FailOSErr(myError);
  436.        }
  437.        //printf("no send error\n");    /// ** DEBUGGING
  438.     
  439.        myError = AEDisposeDesc(&theAE);
  440.        FailOSErr(myError);
  441.        
  442.        //printf("AEDisposeDesc(&theAE) worked \n");    /// ** DEBUGGING
  443.     
  444.        /*** WORKS TO HERE ****/
  445.        /** GET RESULT FROM HYPERCARD ***/
  446.        
  447.        myError = AEGetParamPtr( &theReply, keyErrorNumber, 
  448.               typeChar, &actualType,
  449.           (Ptr)(&eventError), sizeof(eventError), &actualSize);
  450.        if (myError != errAEDescNotFound) {
  451.            // a descriptor was found
  452.           if (myError) {
  453.              myError = AEDisposeDesc( &theReply);
  454.              // SysBeep(1);
  455.                    FailOSErr(myError);
  456.  
  457.           } else {
  458.              if (eventError != noErr) {
  459.                 myError=AEDisposeDesc( &theReply);
  460.                 // SysBeep(1);
  461.              }
  462.           }
  463.        }
  464.     
  465.        myError = AEGetParamDesc(&theReply, keyDirectObject, typeChar, 
  466.           &theResultDescriptor);
  467.        if (myError) { /* no direct object exists ! */
  468.            // there is no reply ?
  469.           myError = AEDisposeDesc( &theReply);
  470.           FailOSErr(myError);
  471.        } else {
  472.            // there is a reply !
  473.            myError = AESizeOfParam( &theReply, keyDirectObject,
  474.                       &theDescriptorType,
  475.               &theResultSize);
  476.            FailOSErr(myError);
  477.         }
  478.            /*****  PUT IT INTO SCRAP -- CRASHES MACHINE if run
  479.            //myError = ZeroScrap();
  480.            // FailOSErr(myError);
  481.            
  482.            //myError = PutScrap( theResultSize, 'TEXT', 
  483.                //    *theResultDescriptor.dataHandle);
  484.            //FailOSErr(myError);
  485.            *****/
  486.         
  487.         
  488.         /**** appears never loaded ***/   
  489.        //myError = AEDisposeDesc(&theResultDescriptor);
  490.        //FailOSErr(myError);
  491.        
  492.        myError = AEDisposeDesc(&theReply);
  493.        FailOSErr(myError);
  494.        
  495.            fSentSuccess = TRUE;      
  496.     
  497.     
  498.         SetCursor(&arrow);
  499.                 /* Use arrow cursor again        */
  500.  
  501.     return fSentSuccess;
  502. }
  503.  
  504.  
  505. - -- 
  506. - ----------------------------------
  507. #include <std/disclaimer.h>     Josh Rabinowitz, Mac TCL programmer
  508. joshr@kronos.arc.nasa.gov
  509. "Me lost my cookie at the disco." -- Cookie Monster
  510.  
  511.  
  512. - -- 
  513. - ----------------------------------
  514. #include <std/disclaimer.h>     Josh Rabinowitz, Mac TCL programmer
  515. joshr@kronos.arc.nasa.gov
  516. "Me lost my cookie at the disco." -- Cookie Monster
  517.  
  518. +++++++++++++++++++++++++++
  519.  
  520. From: rson@rhi.hi.is (Mimir Reynisson)
  521. Date: 5 Feb 93 10:29:45 GMT
  522.  
  523. Well here we go again,
  524.  
  525.  Oki I have support for the four basic AppleEvents (not really hard)
  526. since there's lots of examples on how to do that. However, now I hear
  527. something about being recordable, which apparently means sending
  528. AppleEvents to myself for each user event. Now sending and receiving
  529. AppleEvents is not so hard, but what confuses me is do those "user events"
  530. have to be of a certain class? or type? or what ever? and do they
  531. have to take some special parameters? or do I simply define those AE
  532. for myself, with my own class and type and paramteres?
  533.  
  534. P.S.: I believe that some of the AE docs were in fact written for
  535. green bugeyed aliens, but that's just me I guess.
  536.  
  537. +++++++++++++++++++++++++++
  538.  
  539. From: leonardr@netcom.com (Leonard Rosenthol)
  540. Date: 5 Feb 93 20:32:03 GMT
  541. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  542.  
  543. In article <6144@krafla.rhi.hi.is> rson@rhi.hi.is (Mimir Reynisson) writes:
  544. >Well here we go again,
  545. >
  546. > Oki I have support for the four basic AppleEvents (not really hard)
  547. >since there's lots of examples on how to do that. 
  548. >
  549.     Well that's a start ;)
  550.  
  551. >However, now I hear
  552. >something about being recordable, which apparently means sending
  553. >AppleEvents to myself for each user event. 
  554. >
  555.     Yes and no.  Recordability is only useful if you support "real" Apple
  556. events (ie. something useful beyond the required suite), so that users can
  557. use recording to have scripts (ie. AppleScript) written for them (like a
  558. "Watch me" mode in a communications program).
  559.  
  560. >P.S.: I believe that some of the AE docs were in fact written for
  561. >green bugeyed aliens, but that's just me I guess.
  562. >
  563.     They were - have you ever met Jon Pugh ;)
  564.  
  565. - -- 
  566. - -----------------------------------------------------------------------------
  567. Leonard Rosenthol            Internet:     leonardr@netcom.com
  568. Director of Advanced Technology        AppleLink:    MACgician
  569. Aladdin Systems, Inc.            GEnie:        MACgician
  570.  
  571. +++++++++++++++++++++++++++
  572.  
  573. From: draper@odin.mda.uth.tmc.edu (E.J. Draper)
  574. Date: 5 Feb 1993 22:28:28 GMT
  575. Organization: U.T.M.D. Anderson Cancer Center
  576.  
  577. In article <1993Feb5.203203.6752@netcom.com> Leonard Rosenthol,
  578. leonardr@netcom.com writes:
  579. >>P.S.: I believe that some of the AE docs were in fact written for
  580. >>green bugeyed aliens, but that's just me I guess.
  581.  
  582. I whined about this very topic a few months back in c.s.m.h.  I thought
  583. it was important to let Apple know that there are MANY developers,
  584. including myself, that are utterly befuddled by the object model.  It
  585. seems to me that the documentation should be a heck of a lot less
  586. esoteric and pedantic and a whole lot more useful to somebody trying to
  587. make their application scripting savvy.
  588.  
  589. Has anybody taken the Developer's University course?  Is it worth the
  590. time and cash?
  591.  
  592.  
  593.       |E|J-  ED DRAPER
  594.  rEpar|D|<-  Radiologic/Pathologic Institute
  595.              The University of Texas M.D. Anderson Cancer Center
  596.              draper@odin.mda.uth.tmc.edu
  597.  
  598. +++++++++++++++++++++++++++
  599.  
  600. From: leonardr@netcom.com (Leonard Rosenthol)
  601. Date: 6 Feb 93 05:46:05 GMT
  602. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  603.  
  604. In article <8676@lib.tmc.edu> draper@odin.mda.uth.tmc.edu (E.J. Draper) writes:
  605. >Has anybody taken the Developer's University course?  Is it worth the
  606. >time and cash?
  607. >
  608.     YES!!!!!!
  609.  
  610.     The DU class is probably the BEST way to learn the Object Model and 
  611. Apple events - it's worth every cent!!
  612.  
  613. - -- 
  614. - -----------------------------------------------------------------------------
  615. Leonard Rosenthol            Internet:     leonardr@netcom.com
  616. Director of Advanced Technology        AppleLink:    MACgician
  617. Aladdin Systems, Inc.            GEnie:        MACgician
  618.  
  619. +++++++++++++++++++++++++++
  620.  
  621. From: Jim.Matthews@dartmouth.edu (Jim Matthews)
  622. Date: 8 Feb 93 14:33:14 GMT
  623. Organization: Dartmouth College, Hanover, NH
  624.  
  625. E.J. Draper writes
  626. > Has anybody taken the Developer's University course?  Is it worth the
  627. > time and cash?
  628.  
  629. I "took" the DU self-study course (i.e. the one that APDA sells) and it  
  630. was well worth the time and money.  Between that and reading the article  
  631. in develop issue #10 four or five times I finally feel like I know what's  
  632. going on.  The DU course is especially nice because there are exercises  
  633. and you implement an AE object; it makes all the concepts and abstractions  
  634. real.  
  635.  
  636. It's also very valuable to fool around with Toy Surprise (assuming you can  
  637. get ahold of the AppleScript Beta CD).  You can have your accessors and  
  638. tokens and handlers and terminology all working but you may not see flaws  
  639. in your basic object design until you try to write scripts for your app.   
  640. That experience helps clarify the basic design decisions: whether to make  
  641. something a property or an element, a new class or an extension of an  
  642. existing one, and whether to use a new event or a re-interpretation of a  
  643. core event.
  644.  
  645. There are some things that I still don't understand, and that aren't  
  646. covered in the documentation (such as, what's a reasonable way to  
  647. implement inheritence?), but it's hard enough to get started already.
  648.  
  649. Jim Matthews
  650. Dartmouth Software Development
  651.  
  652. ---------------------------
  653.  
  654. From: mark@pokey.jsc.nasa.gov (Mark Manning)
  655. Subject: Help with strings....
  656. Organization: NASA
  657. Date: Fri, 5 Feb 1993 16:24:11 GMT
  658.  
  659. I have to admit I liked the sprintf thing better than the short
  660. shameful routine I wrote.  Good Thinking!
  661.  
  662. sprintf( newbuf, "This is the number #%d", shortnum );
  663.  
  664. Now why didn't >I< think of that! ;)
  665.  
  666. +++++++++++++++++++++++++++
  667.  
  668. From: heksterb@cs.utwente.nl (Ben Hekster)
  669. Organization: University of Twente, Dept. of Computer Science
  670. Date: Tue, 9 Feb 1993 16:37:37 GMT
  671.  
  672. Ok, since everyone else seems to be posting their favorite string
  673. munging routines, here's mine.  I wrote it in C++ but a quick look
  674. would suggest that it's almost ANSI C.
  675.  
  676.     It works along the lines of the Dialog Manager's ParamText
  677. function, except that there is no bound on the number of arguments
  678. that may be substituted.  Caveat:  the price for this flexibility
  679. is a slight dependency on the order in which your compiler passes
  680. arguments in variable-length argument lists.  This particular code
  681. works under MPW's C++/C.
  682.  
  683. E.g.,
  684.  
  685.     long delay = 2, model = 300;
  686.     unsigned char strDelay[16], strModel[16];
  687.     NumToString(delay, strDelay);
  688.     NumToString(model, strModel);
  689.  
  690.     unsigned char subsituted[256];
  691.     ParamString(
  692.         result,
  693.         "\pI've had my Apple CD^0 on order for ^1 months",
  694.         strModel,
  695.         strDelay
  696.         );
  697.  
  698. constructs the appropriate string in "result".
  699.  
  700.     This scheme has the advantage that your string constructions
  701. aren't hard-coded and can be localized simply by using a different
  702. template string: "\pAinda sa~o ^1 meses que espero por meu CD^0"
  703.  
  704. Enjoy!
  705.  
  706.  
  707. void ParamString(unsigned char *result, const unsigned char *templat, ...);
  708.  
  709.  
  710. /*    ParamString
  711.     Build a Pascal string from the given template and argument substitutions
  712.     An argi may be NULL
  713. */
  714. #pragma segment Main
  715. void ParamString(
  716.     unsigned char *const result,
  717.     const unsigned char *const templat,
  718.     ...                        // const unsigned char *argi
  719.     )
  720. {
  721. const unsigned char **arg = &templat + 1;        // *** implementation-dependent
  722.  
  723. register unsigned char *r = result;
  724. register const unsigned char *t = templat;
  725.  
  726. // keep copying characters from the template into the result
  727. unsigned char rlength = *r++ = 0;
  728. unsigned char tlength = *t++;
  729. while (tlength > 0 && rlength < 255)
  730.     // ordinary character?
  731.     if (*t != '^') {
  732.         *r++ = *t++;
  733.         rlength++; tlength--;
  734.         }
  735.     // argument substitution?
  736.     else {
  737.         t++; tlength--;
  738.  
  739.         // which argument?
  740.         tlength--;
  741.         const unsigned char *a = arg[*t++ - '0'];
  742.     
  743.         // copy the argument into the result
  744.         if (a) for (unsigned char alength = *a++; alength > 0 && rlength < 255; alength--, rlength++)
  745.             *r++ = *a++;
  746.         }
  747.  
  748. *result = rlength;
  749. }
  750.  
  751. - -- 
  752. Ben `Hackster' Hekster          | "In the comfort of this room
  753. heksterb@cs.utwente.nl          |  the challenge died"
  754.  
  755. ---------------------------
  756.  
  757. From: tnorthtj@cc.curtin.edu.au (Tim North)
  758. Subject: Getting a dirID from an FSSpec. HELP!
  759. Organization: Curtin University of Technology
  760. Date: Mon, 8 Feb 1993 01:37:44 GMT
  761.  
  762. 1.    I have an FSSpec for a *folder* that the user has selected using a 
  763.     CustomGetFile dialog.
  764.  
  765. 2.    I then wish to search this folder. No problem. The problem is that the 
  766.     FSSpec contains the dirID for the *parent* directory of the selected 
  767.     folder. So when I say...
  768.  
  769.         StandardFileReply    myReply;
  770.  
  771.         myReply = DoGetDirectory();
  772.         Search(myReply.sfFile.vRefNum, myReply.sfFile.parID); 
  773.  
  774.     ...it searches the *parent* of the selected folder, not the selected
  775.     folder itself.
  776.  
  777. Question: How do I get the dirID of a folder given an FSSpec for it?
  778.  
  779. Many thanks in advance!
  780. Tim North.
  781. - -------------------------------------------------------------------------------
  782.     _--_|\      | Dept Computer Engineering, Curtin University of Technology
  783.    /      \     | Perth. Western Australia. 6102.      Phone: (+61 9) 351 7908
  784. - -->\_.--._/     | Internet: North_TJ@cc.curtin.edu.au  FAX:   (+61 9) 351 2584
  785.          v      |
  786. - -------------------------------------------------------------------------------
  787.  
  788. +++++++++++++++++++++++++++
  789.  
  790. From: brunner@crchh447.NoSubdomain.NoDomain (James Brunner)
  791. Date: Mon, 8 Feb 1993 16:38:53 GMT
  792. Organization: BNR, Inc.
  793.  
  794. In article <1993Feb8.103744.1@cc.curtin.edu.au>, tnorthtj@cc.curtin.edu.au (Tim North) writes:
  795. |> 1.    I have an FSSpec for a *folder* that the user has selected using a 
  796. |>     CustomGetFile dialog.
  797. |> 
  798. |> 2.    I then wish to search this folder. No problem. The problem is that the 
  799. |>     FSSpec contains the dirID for the *parent* directory of the selected 
  800. |>     folder. 
  801. |> 
  802. |> Question: How do I get the dirID of a folder given an FSSpec for it?
  803.  
  804. I don't have time to write the whole thing up, but two ideas come to mind.
  805.  
  806. 1) you could try FSMakeFSSpec to make the spec for an file IN the directory
  807. you want.  Make up a name, FSMakeFSSpec will probably return fnfErr, but the
  808. spec is still valid.  FSMakeFSSpec will resolve partial paths, so you could
  809. do something like (NOT actual code, this is from my head):
  810.  
  811.    FSMakeFSSpec(spec.parID, spec.vRefNum, spec.name+":filename", &newspec)
  812.  
  813. 2) Take a good look at PBGetCatInfo.  (Thanks Peter Lewis for showing me this
  814. one.)  PBGetCatInfo is a great routine, much more powerful than it initially
  815. looks.  It will resolve partial pathnames.
  816. - -- 
  817. - ---------------------------------------------------------------------------
  818. Jim Brunner - (brunner@bnr.ca)
  819. All opinions are my own and have nothing whatsoever to do with BNR, NT,
  820. NTI, Bell Canada, or any of the BCE corporations or affiliates.
  821.  
  822. +++++++++++++++++++++++++++
  823.  
  824. From: neeri@iis.ethz.ch (Matthias Neeracher)
  825. Date: 8 Feb 93 23:04:40 GMT
  826. Organization: Integrated Systems Laboratory, ETH, Zurich
  827.  
  828. In article <C2528t.FKy@news.rich.bnr.ca>, brunner@crchh447.NoSubdomain.NoDomain (James Brunner) writes:
  829. > In article <1993Feb8.103744.1@cc.curtin.edu.au>, tnorthtj@cc.curtin.edu.au (Tim North) writes:
  830. > |> 1.    I have an FSSpec for a *folder* that the user has selected using a 
  831. > |>     CustomGetFile dialog.
  832. > |> 
  833. > |> 2.    I then wish to search this folder. No problem. The problem is that the 
  834. > |>     FSSpec contains the dirID for the *parent* directory of the selected 
  835. > |>     folder. 
  836. > |> 
  837. > |> Question: How do I get the dirID of a folder given an FSSpec for it?
  838.  
  839. > I don't have time to write the whole thing up, but two ideas come to mind.
  840.  
  841. > 1) you could try FSMakeFSSpec to make the spec for an file IN the directory
  842. > you want.  Make up a name, FSMakeFSSpec will probably return fnfErr, but the
  843. > spec is still valid.  FSMakeFSSpec will resolve partial paths, so you could
  844. > do something like (NOT actual code, this is from my head):
  845.  
  846. >    FSMakeFSSpec(spec.parID, spec.vRefNum, spec.name+":filename", &newspec)
  847.  
  848. > 2) Take a good look at PBGetCatInfo.  (Thanks Peter Lewis for showing me this
  849. > one.)  PBGetCatInfo is a great routine, much more powerful than it initially
  850. > looks.  It will resolve partial pathnames.
  851.  
  852. Something like this might work:
  853.  
  854. CInfoPBRec  info;
  855. FSSpec      fs;  /* Filled in by you */
  856.  
  857. info.dirInfo.ioVRefNum         = fs.vRefNum;
  858. info.dirInfo.ioDrDirID         = fs.parID;
  859. info.dirInfo.ioNamePtr         = fs.name;
  860. info.dirInfo.ioFDirIndex     = -1;
  861. info.dirInfo.filler2         = 0;
  862.  
  863. PBGetCatInfoSync(&info);
  864.  
  865. /* Imagine an error handler for the above :-) */
  866.  
  867. fs.parID    = cb.dirInfo.ioDrParID;
  868.  
  869. Matthias
  870.  
  871. - -----
  872. Matthias Neeracher                                   neeri@iis.ethz.ch
  873.  "You must have picked up that copy of Scarlett instead of Inside Mac
  874.   when you tried to find the right call..." -- Keith Rollin
  875.  
  876. +++++++++++++++++++++++++++
  877.  
  878. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  879. Organization: NCRPDA, Curtin University
  880. Date: Tue, 9 Feb 1993 04:05:45 GMT
  881.  
  882. In article <1993Feb8.103744.1@cc.curtin.edu.au>, tnorthtj@cc.curtin.edu.au
  883. (Tim North) wrote:
  884. > 1.    I have an FSSpec for a *folder* that the user has selected using a 
  885. >     CustomGetFile dialog.
  886.  
  887. > Question: How do I get the dirID of a folder given an FSSpec for it?
  888.  
  889. "Learn to Love PBGetCatInfo"
  890.  
  891. var
  892.   pb:CInfoPBRec;
  893.   fs:FSSpec;
  894.  
  895. pb.ioNamePtr:=@fs.name;
  896. pb.ioVRefNum:=fs.vRefNum;
  897. pb.ioDirID:=fs.parID;
  898. pb.ioFDirIndex:=0;
  899.  
  900. oe:=PBGetCatInfo(@pb,false);
  901.  
  902. The dir ID of the folder is now in ioDrDirID, the par ID of the folder
  903. should be in ioDrParID.
  904.  
  905. PBGetCatInfo is one of the most useful File Manager calls.  Its very simple
  906. to use, it takes only those four parameters above, and will index thru
  907. directories, resolve partial paths, get directory names or ID, etc.
  908.  
  909. Have fun,
  910.    Peter.
  911.  
  912. _______________________________________________________________________
  913. Peter N Lewis <peter@cujo.curtin.edu.au>             Ph: +61 9 368 2055
  914.  
  915. +++++++++++++++++++++++++++
  916.  
  917. From: neeri@iis.ethz.ch (Matthias Neeracher)
  918. Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
  919. Date: Tue, 9 Feb 1993 13:31:42 GMT
  920.  
  921. I stupidly wrote:
  922.  
  923. >In article <C2528t.FKy@news.rich.bnr.ca>, brunner@crchh447.NoSubdomain.NoDomain (James Brunner) writes:
  924. >> In article <1993Feb8.103744.1@cc.curtin.edu.au>, tnorthtj@cc.curtin.edu.au (Tim North) writes:
  925. >> |> 1.    I have an FSSpec for a *folder* that the user has selected using a 
  926. >> |>     CustomGetFile dialog.
  927. >> |> 
  928. >> |> 2.    I then wish to search this folder. No problem. The problem is that the 
  929. >> |>     FSSpec contains the dirID for the *parent* directory of the selected 
  930. >> |>     folder. 
  931. >> |> 
  932. >> |> Question: How do I get the dirID of a folder given an FSSpec for it?
  933.  
  934. >> I don't have time to write the whole thing up, but two ideas come to mind.
  935.  
  936. >> 1) you could try FSMakeFSSpec to make the spec for an file IN the directory
  937. >> you want.  Make up a name, FSMakeFSSpec will probably return fnfErr, but the
  938. >> spec is still valid.  FSMakeFSSpec will resolve partial paths, so you could
  939. >> do something like (NOT actual code, this is from my head):
  940.  
  941. >>    FSMakeFSSpec(spec.parID, spec.vRefNum, spec.name+":filename", &newspec)
  942.  
  943. >> 2) Take a good look at PBGetCatInfo.  (Thanks Peter Lewis for showing me this
  944. >> one.)  PBGetCatInfo is a great routine, much more powerful than it initially
  945. >> looks.  It will resolve partial pathnames.
  946.  
  947. >Something like this might work:
  948.  
  949. >CInfoPBRec  info;
  950. >FSSpec      fs;  /* Filled in by you */
  951.  
  952. >info.dirInfo.ioVRefNum         = fs.vRefNum;
  953. >info.dirInfo.ioDrDirID         = fs.parID;
  954. >info.dirInfo.ioNamePtr         = fs.name;
  955. >info.dirInfo.ioFDirIndex     = -1;
  956.  
  957. Aaaaaarrrgggg !!! Stop the presses. The correct value is 0, not -1
  958.  
  959. >info.dirInfo.filler2         = 0;
  960.  
  961. >PBGetCatInfoSync(&info);
  962.  
  963. >/* Imagine an error handler for the above :-) */
  964.  
  965. >fs.parID    = cb.dirInfo.ioDrParID;
  966.  
  967.  
  968. ---------------------------
  969.  
  970. End of C.S.M.P. Digest
  971. **********************
  972.